package com.itheima.controller;

import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.CheckItem;
import com.itheima.service.CheckItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkitem")
public class CheckItemController {

    @Autowired
    private CheckItemService checkItemService;

    @PostMapping("/findPage.do")
    public PageResult findPage(@RequestBody QueryPageBean page) {
        PageResult result = checkItemService.fingPage(page);
        return result;
    }

    @PostMapping("/add.do")
    public Result add(@RequestBody CheckItem checkItem) {
        Result result = checkItemService.add(checkItem);
        return result;
    }

    @GetMapping("/delete.do")
    public Result delete(String id) {
        Result result = checkItemService.deleteById(id);
        return result;
    }

    @GetMapping("/findById.do")
    public Result findById(Integer id) {
        Result result = checkItemService.findById(id);
        return result;
    }

    @PostMapping("/edit.do")
    public Result update(@RequestBody CheckItem checkItem) {
        Result result = checkItemService.update(checkItem);
        return result;

    }

    @GetMapping("/findAll.do")
    public Result findAll() {
        Result result = checkItemService.findAll();
        return result;

    }
}
